/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package nm;

import methods.NeYavnaya;

/**
 *
 * @author Alexey Chirkov
 */
public class Report {

    public static void main(String[] args) {
        int M = 10;
        int M1;
        int I = 10;
        //Неявная
        M = 100;
        NeYavnaya.getInstance().setK(M);
        I = 100;
        NeYavnaya.getInstance().setI(I);
        M1 = 2 * M + 1;



        double[][] mat1 = new double[M + 1][I + 1];

        double[][] mat2 = new double[M1 + 1][I + 1];
        for (int i = 0; i <= M; i++) {
            for (int j = 0; j <= I; j++) {
                mat1[i][j] = NeYavnaya.getInstance().getValueAt(i, j);
            }
        }
        NeYavnaya.getInstance().setK(M1);
        for (int i = 0; i <= M1; i++) {
            for (int j = 0; j <= I; j++) {
                mat2[i][j] = NeYavnaya.getInstance().getValueAt(i, j);
            }
        }

        double[][] mat = new double[M + 1][I + 1];
        for (int i = 0; i <= M; i++) {
            for (int j = 0; j <= I; j++) {
                if (i != 0) {
                    mat[i][j] = Math.abs(mat1[i][j] - mat2[2 * i + 1][j]);
                } else {
                    mat[i][j] = Math.abs(mat1[i][j] - mat2[0][j]);
                }
            }
        }

        double[] max = new double[M + 1];
        for (int i = 0; i <= M; i++) {
            double maxV = mat[i][0];
            for (int j = 1; j <= I; j++) {
                if (maxV < mat[i][j]) {
                    maxV = mat[i][j];
                }
            }
            max[i] = maxV;
        }
        double maxV1 = max[0];
        for (int i = 1; i <= M; i++) {
            if (maxV1 < max[i]) {
                maxV1=max[i];
            }
        }

        int M2=4*M+3;
        double[][] mat3 = new double[M2+1][I+1];
        NeYavnaya.getInstance().setK(M2);
        for (int i = 0; i <= M2; i++) {
            for (int j = 0; j <= I; j++) {
                mat3[i][j] = NeYavnaya.getInstance().getValueAt(i, j);
            }
        }
        mat = new double[M1 + 1][I + 1];
        for (int i = 0; i <= M1; i++) {
            for (int j = 0; j <= I; j++) {
                if (i != 0) {
                    mat[i][j] = Math.abs(mat2[i][j] - mat3[2 * i + 1][j]);
                } else {
                    mat[i][j] = Math.abs(mat2[i][j] - mat3[0][j]);
                }
            }
        }
        max = new double[M1 + 1];
        for (int i = 0; i <= M1; i++) {
            double maxV = mat[i][0];
            for (int j = 1; j <= I; j++) {
                if (maxV < mat[i][j]) {
                    maxV = mat[i][j];
                }
            }
            max[i] = maxV;
        }
        
        double maxV2 = max[0];
        for (int i = 1; i <= M; i++) {
            if (maxV2 < max[i]) {
                maxV2=max[i];
            }
        }
        
        System.out.println(maxV1/maxV2);
    }
}
